/**
 * ConstraintAbstract
 * ----------------------------------------------
 * 
 * This abstract class represents integrity constraints for xml.
 * 
 * @author caio thomas
 */

package main.constraint;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;

import automata.Fsa;
import automata.State;

public abstract class ConstraintAbstract {
	
	protected String nameConstraint; 
	protected Fsa contextFsa;
	protected Fsa sourceFsa;
	protected Fsa targetFsa;
	protected int npaths = 1;//path defines how the FSA has
	protected Hashtable<Fsa, Hashtable<State, String>> equality = new Hashtable<Fsa, Hashtable<State, String>>();
	protected ArrayList<Integer> j = new ArrayList<Integer>();
	
	public String getNameConstraint() {
		return nameConstraint;
	}
	
	public void setNameConstraint(String nameConstraint) {
		this.nameConstraint = nameConstraint;
	}
	
	public Fsa getContextFsa() {
		return contextFsa;
	}
	
	public void setContextFsa(Fsa contextFsa) {
		this.contextFsa = contextFsa;
	}
	
	public Fsa getSourceFsa() {
		return sourceFsa;
	}
	
	public void setSourceFsa(Fsa sourceFsa) {
		this.sourceFsa = sourceFsa;
	}
	
	public Fsa getTargetFsa() {
		return targetFsa;
	}
	
	public void setTargetFsa(Fsa targetFsa) {
		this.targetFsa = targetFsa;
	}
	
	public int getNpaths() {
		return npaths;
	}
	
	public void setNpaths(int npaths) {
		this.npaths = npaths;
	}
	
	public Hashtable<Fsa, Hashtable<State, String>> getEquality() {
		return equality;
	}
	
	public void setEquality(Hashtable<Fsa, Hashtable<State, String>> equality) {
		this.equality = equality;
	}
	
	public void setJ()
	{
		Iterator<State> i = sourceFsa.get_final_states().iterator();
		
		while (i.hasNext())
		{
			j.add(i.next().elt);
		}
	}
	
	public int getJ(Integer state)
	{
		return j.indexOf(state);
	}
}
